//
//  LHButton.m
//  PassFeed
//
//  Created by passfeediOS on 16/8/15.
//
//

#import "LHButton.h"

#define kTitlePrecent 0.5
#define kImageViewWH  22


@implementation LHButton

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
//        self.backgroundColor=[UIColor greenColor];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        //self.titleLabel.backgroundColor=[UIColor blueColor];
        self.titleLabel.font = [UIFont boldSystemFontOfSize:11];
        [self setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        //self.imageView.layer.cornerRadius = kImageViewWH * 0.5;
        //self.imageView.backgroundColor=[UIColor redColor];
    }
    return self;
}

#pragma mark 调整文字的位置和尺寸
- (CGRect)titleRectForContentRect:(CGRect)contentRect{
    CGFloat titleW = self.frame.size.width;
    CGFloat titleH = self.frame.size.height * kTitlePrecent;
    CGFloat titleX = 1;
    CGFloat titleY = self.frame.size.height * (1 - kTitlePrecent)+3;
    return CGRectMake(titleX, titleY, titleW, titleH);
}

#pragma mark 调整图片的位置和尺寸
- (CGRect)imageRectForContentRect:(CGRect)contentRect{
    CGFloat imageW = kImageViewWH;
    CGFloat imageH = kImageViewWH;
    CGFloat imageX = (self.frame.size.width - kImageViewWH) * 0.5;
    CGFloat imageY = 8;
    return CGRectMake(imageX, imageY, imageW, imageH);
}

@end
